cmake_minimum_required(VERSION 3.15.2)

project(SIMD CXX C)

# set CMAKE_BUILD_TYPE
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE RELEASE)
endif()

string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")

# set CMAKE_BUILD_TARGET_ARCH
# use `lscpu | grep 'Architecture' | awk '{print $2}'` only support system which language is en_US.UTF-8
execute_process(COMMAND bash "-c" "uname -m"
        OUTPUT_VARIABLE
        CMAKE_BUILD_TARGET_ARCH
        OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Build target arch is ${CMAKE_BUILD_TARGET_ARCH}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -mavx")

# Set dirs
set(BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}")
#set(GENSRC_DIR "${BASE_DIR}/../gensrc/build/")
set(SRC_DIR "${BASE_DIR}/")
set(OUTPUT_DIR "${BASE_DIR}/output")

set( Lowercase_SOURCES
       LowerCase.cpp)

set( Sqrt_SOURCES
        Sqrt.cpp)

add_executable(lowercase ${Lowercase_SOURCES})

#target_link_libraries( lowercase libthrift.a libthriftnb.a )


add_executable(sqrt ${Sqrt_SOURCES})
#target_link_libraries( sqrt libthrift.a libthriftnb.a )

# command: make install ,copy the targets executable file lowercase and sqrt to output dir
install(TARGETS
        lowercase sqrt
        DESTINATION ${OUTPUT_DIR})